
global root ""

log using testing_JHR, replace

use "$root\testing_JHR.dta", clear

global indiv "female age migra1 migra2 otherlang dhisced2 dhisced3 dhisced4 dhisced5 dhisced6 bluehigh whitlow whithigh dbook2 dbook3 dbook4"
global institut "numstud private budgetgov sharefulcer mshortea dteaabs2 dteaabs3 dteaabs4 dloc2 dloc3 dloc4 dloc5 GDPpc"
global imp "imfemale image immigra1 imotherlang imdhisced2 imwhithigh imdbook2 imnumstud imprivate imbudgetgov imsharefulcer immshortea imdteaabs2 imdloc2"
global aut "mmaut_content c.mmaut_content#c.i_GDPpc"
global FE "i. wave i.country"
global controls "$indiv $institut $imp $aut $FE"
global ii_scomp "iimmtest_com"
global ii_sint "iimmass_std1 iimmtea_ass"
global ii_irpt "iimmtest_par iimmacc_public"
global ii_tmon "iimmtest_jud"
global ii "iimmass_std1 iimmtea_ass iimmtest_par"
global scomp "mmtest_com exam_lowersec test_career cee_dyn"
global sint "mmass_std1 mmtea_ass mmacc_auth"
global irpt "mmtest_par mmtest_mon mmacc_public"
global tmon "mmtest_jud mmtea_prin mmtea_insp"
global institut2 "numstud private budgetgov dloc2 dloc3 dloc4 dloc5 GDPpc"
global imp2 "imfemale image immigra1 imotherlang imdhisced2 imwhithigh imdbook2 imnumstud imprivate imbudgetgov imdloc2"


* Table 1: Descriptive statistics of testing measures 

sum scomp $scomp sint $sint irpt $irpt tmon $tmon [w=wgt]


* Table 2: The average effect of different forms of student testing on student achievement: Fixed-effects panel models

foreach x in math scie read {
reg pv1`x' scomp sint irpt tmon $ii $controls [pw=wgt], vce(cluster country)
}


* Table 3: Effects of student testing by initial achievement level: Fixed-effects panel models

foreach x in math scie read {
reg pv1`x' scomp c.scomp#c.i_pv1`x' sint c.sint#c.i_pv1`x' irpt c.irpt#c.i_pv1`x' tmon c.tmon#c.i_pv1`x' $ii $controls [pw=wgt], vce(cluster country)
}
foreach x in math scie read {
reg pv1`x' sint c.sint#c.i_pv1`x' irpt c.irpt#c.i_pv1`x' tmon c.tmon#c.i_pv1`x' immtest_com c.immtest_com#c.i_pv1`x' compare234 c.compare234#c.i_pv1`x' $ii $controls [pw=wgt], vce(cluster country)
}


* Table 4: Estimations for separate underlying testing indicators

foreach x in math scie read {
foreach var of varlist $scomp $sint $irpt $tmon {
reg pv1`x' `var' c.`var'#c.i_pv1`x' $controls [pw=wgt], vce(cluster country)
}
}


* Table 5: Placebo test with leads of testing reforms 

foreach x in math scie read {
reg pv1`x' scomp sint irpt tmon f1_scomp f1_sint f1_irpt f1_tmon $ii $controls [pw=wgt], vce(cluster country)
}


* Table 6: Specification tests 

reg pv1math scomp c.scomp#c.i_pv1math sint c.sint#c.i_pv1math irpt c.irpt#c.i_pv1math tmon c.tmon#c.i_pv1math $ii $indiv $institut2 $imp2 $aut $FE [pw=wgt], vce(cluster country)
reg pv1math scomp c.scomp#c.i_pv1math sint c.sint#c.i_pv1math irpt c.irpt#c.i_pv1math tmon c.tmon#c.i_pv1math $ii $FE [pw=wgt], vce(cluster country)
reg pv1math scomp c.scomp#c.i_pv1math sint c.sint#c.i_pv1math irpt c.irpt#c.i_pv1math tmon c.tmon#c.i_pv1math $ii $controls [pw=wgt] if (wave==2000 | wave==2002 | wave==2015) & p00_15==1, vce(cluster country)
reg pv1math scomp c.scomp#c.i_pv1math $ii_scomp $controls [pw=wgt] if (wave==2000 | wave==2002 | wave==2015) & p00_15==1, vce(cluster country)
reg pv1math c.scomp#c.im1 c.scomp#c.im2 c.scomp#c.im3 c.scomp#c.im4 c.sint#c.im1 c.sint#c.im2 c.sint#c.im3 c.sint#c.im4 c.irpt#c.im1 c.irpt#c.im2 c.irpt#c.im3 c.irpt#c.im4 c.tmon#c.im1 c.tmon#c.im2 c.tmon#c.im3 c.tmon#c.im4 $ii $controls [pw=wgt], vce(cluster country)


* Table 7: Robustness tests 

reg pv1math scomp c.scomp#c.i_pv1math sint c.sint#c.i_pv1math irpt c.irpt#c.i_pv1math tmon c.tmon#c.i_pv1math $ii $controls [pw=wgt] if oecd, vce(cluster country)
reg pv1math scomp sint c.sint#c.i_pv1math irpt tmon c.tmon#c.i_pv1math $ii $controls [pw=wgt] if oecd, vce(cluster country)
reg pv1math scomp c.scomp#c.i_pv1math sint c.sint#c.i_pv1math irpt c.irpt#c.i_pv1math tmon c.tmon#c.i_pv1math $ii $controls [pw=wgt] if oecd==0, vce(cluster country)
reg pv1math scomp c.scomp#c.i_pv1math sint c.sint#c.i_pv1math irpt c.irpt#c.i_pv1math tmon c.tmon#c.i_pv1math excl $ii $controls [pw=wgt], vce(cluster country)
reg pv1math scomp c.scomp#c.i_pv1math sint c.sint#c.i_pv1math irpt c.irpt#c.i_pv1math tmon c.tmon#c.i_pv1math $ii $controls [pw=wgt] if wave~=2015, vce(cluster country)
reg rescale_pv1math scomp c.scomp#c.i_pv1math sint c.sint#c.i_pv1math irpt c.irpt#c.i_pv1math tmon c.tmon#c.i_pv1math $ii $controls [pw=wgt], vce(cluster country)


* Table A1: Selected indicators by country

preserve 
bysort cnt: egen minwave=min(wave)
bysort cnt: egen maxwave=max(wave)
keep if wave==minwave | wave==maxwave
replace wave=2000 if wave==minwave
replace wave=2015 if wave==maxwave
collapse (mean) oecd pv1math $scomp [pweight=wgt], by(country wave)
xtset country wave
reshape wide pv1math $scomp, i(country) j(wave)
merge m:1 country using "$root\codes"
drop if _merge~=3
sort country_name
list country_name cnt oecd p* 
list cnt m* e* t* ce*
list country_name cnt oecd p* m* e* t* ce*
restore


* Table A2: Descriptive statistics and complete model of basic specification

sum $indiv $institut $aut migra0 bluelow dbook1 dteaabs1 dloc1 [w=wgt]
sum $imp
reg pv1math scomp c.scomp#c.i_pv1math sint c.sint#c.i_pv1math irpt c.irpt#c.i_pv1math tmon c.tmon#c.i_pv1math $controls $ii [pw=wgt], vce(cluster country)


* Table A4: Country observations by wave 

preserve 
replace wave=2000 if wave==2002
replace wave=2009 if wave==2010
collapse (mean) iimmtest_com exam_lowersec test_career cee_dyn iimmass_std1 iimmtea_ass iimmacc_auth iimmtest_par iimmtest_mon iimmacc_public iimmtest_jud iimmtea_prin iimmtea_insp, by(country wave)
foreach var of varlist iimmtest_com exam_lowersec test_career cee_dyn iimmass_std1 iimmtea_ass iimmacc_auth iimmtest_par iimmtest_mon iimmacc_public iimmtest_jud iimmtea_prin iimmtea_insp{
tab `var' wave
}
restore


* Table A5: Correlation of four testing categories 

preserve
collapse (mean) scomp sint irpt tmon [pweight=wgt], by(country wave)
pwcorr scomp sint irpt tmon, sig
foreach x in scomp sint irpt tmon {
reg `x' i. wave i.country
predict r_`x', res 
}
pwcorr r_scomp r_sint r_irpt r_tmon, sig
restore


* Table A6: Disaggregation of standardized external comparison into school-based and student-based comparison

foreach x in math scie read {
reg pv1`x' immtest_com compare234 sint irpt tmon $ii $controls [pw=wgt], vce(cluster country)
}


* Table A7: Estimations for separate underlying testing indicators: Specification with average effects

foreach x in math scie read {
foreach var of varlist $scomp $sint $irpt $tmon {
reg pv1`x' `var' $controls [pw=wgt], vce(cluster country)
}
}


* Table A8: Correlation of testing reforms with other school policy measures  

preserve
collapse (mean) scomp sint irpt tmon mmaut_content numstud sharefulcer mshortea private budgetgov [pweight=wgt], by(country wave)
foreach x in scomp sint irpt tmon mmaut_content numstud sharefulcer mshortea private budgetgov {
reg `x' i. wave i.country
predict r_`x', res 
}
pwcorr r_scomp r_sint r_irpt r_tmon r_mmaut_content r_numstud r_sharefulcer r_mshortea r_private r_budgetgov, sig
restore


* Table A9: Specification tests: Specification with average effects

reg pv1math scomp sint irpt tmon $ii $indiv $institut2 $imp2 $aut $FE [pw=wgt], vce(cluster country)
reg pv1math scomp sint irpt tmon $ii $FE [pw=wgt], vce(cluster country)
reg pv1math scomp sint irpt tmon $ii $controls [pw=wgt] if (wave==2000 | wave==2002 | wave==2015) & p00_15==1, vce(cluster country)


* Table A10: Robustness tests: Specification with average effects

reg pv1math scomp sint irpt tmon $ii $controls [pw=wgt] if oecd, vce(cluster country)
reg pv1math scomp sint irpt tmon $ii $controls [pw=wgt] if oecd==0, vce(cluster country)
reg pv1math scomp sint irpt tmon excl $ii $controls [pw=wgt], vce(cluster country)
reg pv1math scomp sint irpt tmon $ii $controls [pw=wgt] if wave~=2015, vce(cluster country)
reg rescale_pv1math scomp sint irpt tmon $ii $controls [pw=wgt], vce(cluster country)


* Table A11: Correlation of computer indicators in 2012 with change in PISA score from 2012 to 2015 at the country level

preserve
use "$root\comp.dta", clear
pwcorr d_math d_scie d_read ratcmp15 compweb sc14q07 sc14q08 sc14q09 st26q04 st27q03 st26q05 st26q06 st49q07 st57q06, sig
restore


* Table A12: Two-stage estimation: Panel model estimated at country-by-wave level 

preserve
foreach x in math scie read {
reg pv1`x' $ii $controls [pw=wgt], vce(cluster country)
predict res_`x', res
}
collapse (mean) res_math res_scie res_read scomp sint irpt tmon i_pv1math i_pv1scie i_pv1read [pweight=wgt], by(country wave)
foreach x in math scie read {
reg res_`x' scomp c.scomp#c.i_pv1`x' sint c.sint#c.i_pv1`x' irpt c.irpt#c.i_pv1`x' tmon c.tmon#c.i_pv1`x' $FE, vce(cluster country)
}
restore


* Table A13: Two-stage estimation: Panel model estimated at country-by-wave level, specification with average effects

preserve
foreach x in math scie read {
reg pv1`x' $ii $controls [pw=wgt], vce(cluster country)
predict res_`x', res
}
collapse (mean) res_math res_scie res_read scomp sint irpt tmon [pweight=wgt], by(country wave)
foreach x in math scie read {
reg res_`x' scomp sint irpt tmon $FE, vce(cluster country)
}
restore


* Figure 1:	Fifteen-year changes in standardized external comparison and in student achievement

preserve
reg pv1math sint irpt tmon $ii $controls [pw=wgt] if (wave==2000 | wave==2002 | wave==2015) & p00_15==1 & scomp~=., vce(cluster country)
predict y, res
sum pv1math [w=wgt] if (wave==2000 | wave==2002 | wave==2015) & p00_15==1 & scomp~=.
gen ym = y + r(mean)
reg scomp sint irpt tmon $ii $controls [pw=wgt] if (wave==2000 | wave==2002 | wave==2015) & p00_15==1 & pv1math~=., vce(cluster country)
predict x, res
sum scomp [w=wgt] if (wave==2000 | wave==2002 | wave==2015) & p00_15==1 & pv1math~=.
gen xm = x + r(mean)
replace wave=2000 if wave==2002
keep if (wave==2000 | wave==2002 | wave==2015) & p00_15==1 & pv1math~=. & scomp~=.
collapse (mean) pv1math scomp y ym x xm [pweight=wgt], by(country wave)
xtset country wave
reshape wide pv1math scomp y ym x xm, i(country) j(wave)
for any pv1math scomp y x: gen dX = X2015 - X2000
sum dpv1math
gen dym=dy+r(mean)
sum dscomp
gen dxm=dx+r(mean)
merge m:1 country using "$root\codes"
scatter dym dxm, mlabel(cnt) msymbol(none) mlabpos(0) mlabcolor(black) graphregion(fcolor(white)) ylabel(-40(20)40, nogrid angle(0)) xtitle("Conditional change in standardized external comparison") ytitle("Conditional change in PISA math score") || lfit dym dxm, legend(off) lcolor(black) saving(fig1, replace)
restore


* Figure 2: Histograms of change in four categories of student testing, 2000-2015

preserve
replace wave=2000 if wave==2002
replace wave=2009 if wave==2010
collapse (mean) scomp sint irpt tmon [pweight=wgt], by(country wave)
xtset country wave
reshape wide scomp sint irpt tmon, i(country) j(wave)
foreach x in scomp sint irpt tmon {
gen d`x' = `x'2015 - `x'2000
hist d`x', freq width(.1) start(-.4) xscale(r(-.4 1)) xlab(-.4(.2)1) yscale(r(0 15)) ylab(0(5)15) graphregion(fcolor(white)) xtitle("") fcolor(gray) color(black) saving(fig2_`x', replace)
}
restore


* Figure 3: Effect of student testing on math performance by initial achievement levels 

reg pv1math scomp c.scomp#c.i_mmpv1math sint c.sint#c.i_mmpv1math irpt c.irpt#c.i_mmpv1math tmon c.tmon#c.i_mmpv1math $ii $controls [pw=wgt], vce(cluster country)
foreach var of varlist scomp sint irpt tmon {
margins, dydx(`var') at (i_mmpv1math=(290(65)565))
marginsplot, recast(line) recastci(rarea) yline(0, lpattern(dash)) xlabel(300 350 400 450 500, angle(45)) ylabel(-100 0 100 200 300, angle(45)) xtitle(" Country’s initial PISA score", size(small)) ytitle("Effect of assessment dimension on PISA math score", size(small)) title("") scheme(s1mono) legend(off) saving(fig3_`var', replace)
}


* Figure A1: PISA math achievement in 2000-2015 

preserve
collapse (mean) mmpv1math=pv1math i_high [pw=wgt], by(cnt wave)
twoway (connected mmpv1math wave, mcolor(black) msize(small)) if i_high, by(cnt, cols(10)) aspect(0.5) xlabel(2000 2003 2006 2009 2012 2015, angle(45) labsize(small)) ylabel(450 500 550, angle(45) labsize(small)) xtitle("") ytitle("") yline(450, lcolor(gs13)) yline(500, lcolor(gs13) ) yline(550, lcolor(gs13)) scheme(s1mono) legend(off) saving(figA1a, replace)
twoway (connected mmpv1math wave, mcolor(black) msize(small)) if i_high==0, by(cnt, cols(10)) aspect(0.5) xlabel(2000 2003 2006 2009 2012 2015, angle(45) labsize(small)) ylabel(300 400 500, angle(45) labsize(small)) xtitle("") ytitle("") yline(300, lcolor(gs13)) yline(400, lcolor(gs13) ) yline(500, lcolor(gs13)) scheme(s1mono) legend(off) saving(figA1b, replace)
restore


* Figure A2: School-based external comparison in 2000-2015 

preserve
collapse (mean) mmtest_com [pw=wgt], by(cnt wave)
twoway (connected mmtest_com wave, lcolor(black gs8) mcolor(black gs8) legend(off)), by(cnt, cols(10) legend(off)) aspect(0.5) xlabel(2000 2003 2006 2009 2012 2015, angle(45) labsize(medium)) ylabel(0 1) yline(1, lcolor(gs13)) yline(0, lcolor(gs13)) xtitle("") ytitle("") scheme(s1mono) saving(figA2, replace)
restore


log close
